package com.tianshuo.importtest;

import com.tianshuo.mybatis.model.UserServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @ClassName : UserImport
 * @Description : 测试@Import拓展点
 * @Author : tianshuo
 * @Date: 2020-09-08 16:53
 */
public class UserImport implements ImportBeanDefinitionRegistrar {
    Logger logger = LoggerFactory.getLogger(UserImport.class);

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        logger.error("UserImport: {}",importingClassMetadata);
        GenericBeanDefinition genericBeanDefinition = new GenericBeanDefinition();
        genericBeanDefinition.setBeanClass(UserServiceImpl.class);
        registry.registerBeanDefinition("userService",genericBeanDefinition);
    }
}

